import axios from './axios'
import qs from 'qs'

import {getFixedPricePartList, setFixedPrice, fixedPriceHistory} from './fixedPrice'
import {getPartDetail, getPartList, getPartStockDetail, addPart, changePartPrice, modifyPart, modQty, showHistoryPrice} from './part'
import {upLoadFile, upLoadFiles} from "./upload";

export {getPartDetail, getPartList, getPartStockDetail, addPart, changePartPrice, modifyPart, modQty, showHistoryPrice}
export {getFixedPricePartList, setFixedPrice, fixedPriceHistory}
export {upLoadFiles, upLoadFile}

//获取员工列表
export function getEmployeeList() {
    const data = qs.stringify({pageSize: 5000});
    return axios.post('/employee/manage/get_all_employee_list.do', data).then(res => Promise.resolve(res.data))
}

//获取客户列表
export function getCustomerList(belongModule) {
    const url = belongModule ? '/customer/manage/get_customer_list.do?belongModule=' + belongModule : '/customer/manage/get_customer_list.do';
    return axios.get(url).then(res => Promise.resolve(res.data))
}

//新增员工
export function addEmployee(employee) {
    const data = qs.stringify(employee);
    return axios.post('/employee/manage/save_base_information.do', data).then(res => Promise.resolve(res.data))
}

export function modEmplyee(employee) {
    const data = qs.stringify(employee);
    return axios.post('/employee/manage/improve_information.do', data).then(res => Promise.resolve(res.data))
}


export function userLogin({username, password}) {
    return axios.post('/user/login', qs.stringify({username, password})).then(res => Promise.resolve(res.data))
}

export function checkInventory(formData) {
    //  pandian
    return axios.post('/inventory/manage/excel_stock_inventory.do', formData, {
        headers: {'Content-Type': 'multipart/form-data'}
    }).then(res => Promise.resolve(res.data))
}

export function getUniSystem() {
    return axios.get('/spare_parts/manage/select_system_name.do').then(res => Promise.resolve(res.data))
}

export function getUniUnit() {
    return axios.get('/spare_parts/manage/select_host_num.do').then(res => Promise.resolve(res.data))
}

//查询配件在库情况
export function getInventoryPart() {
    return axios.post('/spare_parts/manage/select_spare_parts_and_stock.do').then(res => Promise.resolve(res.data))
}

//查询配件发货备货情况
export function partDeliveryStatus(partsId, belongModule) {
    return axios.post('/import_and_export/manage/show_ready_and_sends_detail.do', qs.stringify({
        partsId,
        belongModule
    })).then(res => Promise.resolve(res.data))
}

//根据仓库地点配件编号分页查询在库信息
export function getInventoryList1(search) {
    return axios.post('/warehouse/manage/spare_parts_in_stock.do', qs.stringify(search)).then(res => Promise.resolve(res.data))
}

//根据仓库地点配件编号分页查询在库信息
export function getInventoryList(search) {
    return axios.post('/optimization_inventory/manage/spare_parts_inventory.do', qs.stringify(search)).then(res => Promise.resolve(res.data))
}

export function userLog() {
    return axios.get('/user/show_all_login_logs.do').then(res => Promise.resolve(res.data))
}

export function deleteEmployee(id) {
    return axios.get('/employee/manage/delete_employee.do?id=' + id).then(res => Promise.resolve(res.data))
}



// heli价格列表
export function getHeliPrice() {
    return axios.get('/features_for_heli/manage/show_heli_price_list.do').then(({data}) => Promise.resolve(data))
}

export function getHeliPriceChange(partsId) {
    return axios.get(`/features_for_heli/manage/show_history_price.do?partsNumber=${partsId}`).then(({data}) => Promise.resolve(data))
}

//获取三号仓库的库存
export function getWarehouse3Stock() {
    return axios.get('/iec_purchase/manage/show_three_warehouse_parts.do').then(res => Promise.resolve(res.data))
}

//获取物料类别表
export function getMaterialList() {
    return axios.get('/spare_parts/manage/show_material_type_list.do').then(res => Promise.resolve(res.data))
}

//增加物料
export function addMaterial(materialType) {
    return axios.post('/spare_parts/manage/add_material_type.do', qs.stringify({materialType}))
        .then(res => Promise.resolve(res.data))
}

//修改物料
export function modMaterial({id, materialType}) {
    return axios.post('/spare_parts/manage/update_material_type.do\n', qs.stringify({materialType, id}))
        .then(res => Promise.resolve(res.data))
}

//删除
export function deleteMaterial(id) {
    return axios.get('/spare_parts/manage/delete_material_type.do?id=' + id).then(res => Promise.resolve(res.data))
}

/* _____________*****************************************************************************************************/

//部门列表
export function getDepartmentList() {
    return axios.post('/department/manage/show_dept_list.do').then(res => Promise.resolve(res.data))
}

//增加部门
export function addDepartment({
                                  deptName,
                                  parentId,
                                  remarks
                              }) {
    return axios.post('/department/manage/add_department.do', qs.stringify({
        deptName,
        parentId,
        remarks
    })).then(res => Promise.resolve(res.data))

}

//修改部门
export function modDepartment({
                                  deptId, deptName, parentId, remarks
                              }) {
    return axios.post('/department/manage/update_department.do', qs.stringify({
        deptId,
        deptName,
        parentId,
        remarks
    })).then(res => Promise.resolve(res.data))
}

export function deleteDepartmentId(deptId) {
    return axios.get('/department/manage/delete_department.do?deptId=' + deptId).then(res => Promise.resolve(res.data))
}

/* _____________*****************************************************************************************************/

//人力资源列表
export function getHumanResource() {
    return axios.get('/man_power_service_station/manage/show_service_station_list.do').then(res => Promise.resolve(res.data))
}

export function addHumanResource(human) {
    return axios.post('/man_power_service_station/manage/add_service_station.do', qs.stringify(human)).then(res => Promise.resolve(res.data))
}

export function modHumanResource(human) {
    return axios.post('/man_power_service_station/manage/update_service_station.do', qs.stringify(human)).then(res => Promise.resolve(res.data))
}

export function humanList(human) { //deptId，basicSalary，position，positionNumber
    return axios.post('/man_power_service_station/manage/show_basic_list.do', qs.stringify(human)).then(res => Promise.resolve(res.data))
}

/* _____________*****************************************************************************************************/